package com.pilipala.controller;

import com.pilipala.dto.CodeDTO;
import com.pilipala.result.Result;
import com.pilipala.service.CodeService;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/code")
@Slf4j
@Tag(name = "发送验证码相关接口")
public class CodeController {

    @Autowired
    private CodeService codeService;
    /**
     * 发送验证码
     * @param codeDTO 包含email
     * @return 返回成功结果
     */
    @PostMapping("/sendCode")
    public Result<?> sendCode(@RequestBody CodeDTO codeDTO){
        log.info("发送验证码给{}中",codeDTO.getEmail());
        codeService.sendCode(codeDTO);
        return Result.success();
    }
}
